using FireStarterModeller.BO;

namespace FireStarterModeller.Test.BO
{
    // Provides a part of the TestUtils class that creates sample TransactionLogEntry objects.
    // If these methods create invalid data, then implement custom overrides in the
    // TestUtils class.
    public class TestUtilsTransactionLogEntry
    {
        /// <summary>
        /// Creates a new saved TransactionLogEntry with a random value assigned to every property
        /// </summary>
        public static TransactionLogEntry CreateSavedTransactionLogEntry()
        {
            TransactionLogEntry transactionLogEntry = CreateUnsavedValidTransactionLogEntry();
            transactionLogEntry.Save();
            return transactionLogEntry;
        }

        /// <summary>
        /// Creates a new unsaved TransactionLogEntry with a random value assigned to every property
        /// </summary>
        public static TransactionLogEntry CreateUnsavedValidTransactionLogEntry()
        {
            TransactionLogEntry transactionLogEntry = new TransactionLogEntry();
            transactionLogEntry.TransactionSequenceNo = TestUtilsShared.GetRandomInt();
            transactionLogEntry.DateTimeUpdated = TestUtilsShared.GetRandomDate();
            transactionLogEntry.WindowsUser = TestUtilsShared.GetRandomString(255);
            transactionLogEntry.LogonUser = TestUtilsShared.GetRandomString(255);
            transactionLogEntry.MachineName = TestUtilsShared.GetRandomString(255);
            transactionLogEntry.BusinessObjectTypeName = TestUtilsShared.GetRandomString(255);
            transactionLogEntry.CRUDAction = TestUtilsShared.GetRandomString(255);
            transactionLogEntry.DirtyXML = null;
            transactionLogEntry.BusinessObjectToString = TestUtilsShared.GetRandomString(255);
            return transactionLogEntry;
        }

        /// <summary>
        /// Creates a new unsaved TransactionLogEntry where all properties are null, except ID properties
        /// and those with default values.  If there are compulsory properties without
        /// defaults, saving the object will throw an exception.
        /// </summary>
        public static TransactionLogEntry CreateUnsavedDefaultTransactionLogEntry()
        {
            TransactionLogEntry transactionLogEntry = new TransactionLogEntry();
            return transactionLogEntry;
        }
    }
}